//
//  VCDateSelect.swift
//  AirlineReservation
//
//  Created by Kevin on 2020/1/24.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class VCDateSelect: VCBase,MonthDayViewDelegate {
    
    // 星期
    private lazy var weekDayView: WeekDayView = {
        let ui = WeekDayView()
        ui.backgroundColor = COLOR_BACKGROUND
        ui.frame = CGRect(x: 0, y: realHeight, width: SCREEN_WIDTH, height: MARGIN40)
        return ui
    }()
    
    // 月日
    private lazy var monthDayView: MonthDayView = {
        let ui = MonthDayView()
        ui.delegate = self
        let uiY = weekDayView.frame.maxY
        ui.frame = CGRect(x: 0, y: uiY, width: SCREEN_WIDTH, height: SCREEN_HEIGHT - uiY)
        return ui
    }()
    
    // MARK: 回调
    public var complete: ((_ date:String) -> Void)?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        init_set()
        init_views()
    }
    
    func retrunDate(date: String) {
        if let callback = complete {
            callback(date)
        }
        navigationController?.popViewController(animated: true)
    }
}

extension VCDateSelect {
    
    private func init_views() -> Void {
        view.addSubview(weekDayView)
        view.addSubview(monthDayView)
    }
    
    private func init_set() -> Void {
        view.backgroundColor = UIColor.white
    }
}
